<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <base href="<%=basePath%>">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <title>Title</title>
    <script src="js/jquery-1.8.0.js"></script>
    <link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
    <script>
        $(function(){
            $("#ch_checkall,#top_ch_checkall").click(function(){
                if(this.checked){
                    $("input[name=ck_id]").attr("checked","checked");
                }else{
                    $("input[name=ck_id]").removeAttr("checked");
                }
            });

            $("table tr").mouseover(function(){
                $(this).css("background","#D3EAEF");
                $(this).siblings().css("background","white");
            });
        });

        $(function(){
            var s=$("#sa").attr("name");
            $.ajax({
                url: "GoodsServlet",
                type: "post",
                dataType:"json",
                data: {
                    flag: "smallc", parentId: s
                },
                success: function (data) {
                    $.each(data, function () {
                        var str = " <td>"+this.cateName+"</td>" +
                            "<td><a href='CateServlet?flag=supdate&id=" +this.id+ "'"+">修改</a>" +
                            "<td><a href='CateServlet?flag=del&id=" +this.id+ "'"+">删除</a>" +
                            "</td>";
                        $("#sa").append(str);
                    });
                }
            });
        });
        function f(a) {
            if(a=='[]'){
                return confirm("确定删除吗");
            }else {
                alert("子序列有数据，无法删除");
                return false;
            }
        }

    </script>

</head>
<body>
<div class ="div_title">
    <div class="div_titlename"> <img src="images/san_jiao.gif" ><span>商品分类维护</span></div>
</div>

<form action="xxx"  name="form1">

    <table class="main_table" >
        <tr>
           </th>	<th colspan="2">一级分类</th> 	<th colspan="2">二级分类</th>
        </tr>
        <c:forEach var="c" items="${blist}">

            <tr>
                <td>
                    ${c.cateName} <br>
                </td>
                <td>
                            <a href="CateServlet?flag=bupdate&id=${c.id}">修改</a> |
                            <a href="CateServlet?flag=del&id=${c.id}" name="${c.catelist}" onclick="return f(this.name)">删除</a>

                </td>
                <td>
                    <c:forEach var="x" items="${c.catelist}">
                        ${x.cateName} <br>
                    </c:forEach>
                </td>
                <td>
                    <c:forEach var="x" items="${c.catelist}">
                        <a href="CateServlet?flag=supdate&id=${x.id}">修改</a> |
                        <a href="CateServlet?flag=del&id=${x.id}" onclick="return confirm('确定删除吗')">删除</a><br>
                    </c:forEach>
                </td>

                </c:forEach>
            </tr>

    </table>
</form>
</body>
</html>
